import router from './router'
import store from './store'
import { Dialog } from 'vant'
console.log(store.getters.token)
router.beforeEach((to, from, next) => {
  // console.log(to.meta)
  document.title = to.meta.title
  if (!to.meta.verifyToken) {
    next()
  } else { // 判断用户是否进行登录
    if (store.getters.token) {
      next()
    } else {
      Dialog.alert({
        title: '温馨提示',
        message: '您还未登录,无法查看当前页面，为了您更好的体验，请先登录！',
        confirmButtonText: '去登录',
        showCancelButton: true
      }).then(() => {
        next(`/signin?redirect=${to.path}`)
      }).catch(() => {})
    }
  }
})
